#include <bits/stdc++.h>

using namespace std;

using ll = long long;
using pii = pair<int, int>;

const int N = 2e5 + 5;
const int MOD = 998244353;

int n, a[N];
ll dp[N], sum[N];

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
#endif
    ios::sync_with_stdio(false), cin.tie(0);

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];

    dp[1] = sum[1] = 1;

    int pos1 = 0, pos2 = 0;
    for (int i = 2; i <= n; i++) {
        dp[i] = (dp[i] + dp[i-1]) % MOD;
        
        if (a[i] == a[i-2] && a[i] != a[i-1] && i >= 3)
            dp[i] = (dp[i] + dp[i-2]) % MOD;

        if (a[i] == a[i-1]) pos2 = i-1;

        if (a[i] != a[i-2] && i >= 3) pos1 = i-2;

        if (pos1 > pos2) {
            dp[i] = (dp[i] + sum[pos1] - sum[pos2] + MOD) % MOD;
        }

        sum[i] = (sum[i-1] + dp[i]) % MOD;
    }
    cout << dp[n] << endl;
    return 0;
}